package hushi.controller;

import hushi.entity.User;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;

/**
 * RequestPqram(value = "xxx",required = fasle/ture,defaultValue = "自己写的默认值")【数据类型】 名称
 * 说明：指定请求参数的名称
 */

@Controller
@RequestMapping("user")
public class PojoTest {
    @RequestMapping("datepojo")
    public ModelAndView doAdd(@RequestParam(value = "name",required = false,defaultValue = "admin") String name,
                              @RequestParam(value = "tel",required = false,defaultValue = "176") String tel,
                              @RequestParam(value = "email",required = false,defaultValue = "123@qq.com") String email,
                              @RequestParam(value = "date",required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date date){
        System.out.println(name);
        System.out.println(tel);
        System.out.println(email);
        System.out.println(date);
        return new ModelAndView("/date.jsp");
    }

    @RequestMapping("dateclass")
    public ModelAndView doAdd(User user){
        System.out.println(user);
        return new ModelAndView("/date.jsp");
    }

}
